package cn.xz.ruler.demo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import cn.xz.ruler.demo.view.RulerView

class MainActivity : AppCompatActivity() {

    private lateinit var mRulerView: RulerView
    private lateinit var mShowTv: TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        mRulerView = findViewById(R.id.rulerV)
        mShowTv = findViewById(R.id.showTv)

        mRulerView?.setOnScaleChangeListener(object : RulerView.OnScaleChangeListener {
            override fun onScaleFinish(scale: Int) {
                mShowTv?.text = "${scale / 10f}cm"
            }

            override fun onScaleChange(scale: Int) {
                mShowTv?.text = "${scale / 10f}cm"
            }
        })
    }
}